# -*- coding:utf-8 -*-
from fastapi import APIRouter
from core.response import success, fail

router = APIRouter()

@router.get("/auth/captcha")
def captcha():
    return success("OK", {"captcha":False, "code":True})


@router.post("/auth/login")
def login():
    return success("OK", { "accessTokenExpire": "2024-02-16 00:50:36", "refreshTokenExpire": "2024-02-29 22:50:36", "access_token": "8acb0464883c455e8f28997c5f41e0d8", "refresh_token": "abf76365d5d14ee4a274cb1d584d88e5"})

@router.get("/user/info")
def info():
    data = {
        "id": 10000,
        "username": "admin",
        "realName": "admin",
        "avatar": "https://cdn.maku.net/images/avatar.png",
        "gender": 0,
        "email": "babamu@126.com",
        "mobile": "13612345678",
        "status": 1,
        "superAdmin": 1
    }
    return success("OK", data)

@router.get("/menu/authority")
async def authority():
    ret =  [
        "sms:platform:save",
        "sys:role:page",
        "sys:user:export",
        "schedule:run",
        "sys:attachment:delete",
        "sys:operate:all",
        "sms:platform:page",
        "sys:user:page",
        "sys:role:list",
        "sys:post:save",
        "sys:dict:info",
        "sys:org:info",
        "sys:post:delete",
        "sys:role:save",
        "monitor:user:all",
        "sys:org:update",
        "monitor:cache:all",
        "sys:role:update",
        "sys:log:login",
        "sys:org:list",
        "sys:post:page",
        "sys:user:save",
        "schedule:delete",
        "sms:platform:update",
        "monitor:server:all",
        "sys:menu:update",
        "sys:menu:delete",
        "schedule:info",
        "sys:dict:delete",
        "sys:menu:list",
        "sys:params:all",
        "sms:platform:info",
        "sys:dict:page",
        "sys:user:import",
        "sys:user:delete",
        "sys:org:save",
        "sys:menu:info",
        "sys:user:update",
        "schedule:log",
        "sys:role:menu",
        "sys:post:info",
        "sys:post:update",
        "schedule:update",
        "sys:menu:save",
        "schedule:page",
        "sms:platform:delete",
        "sys:org:delete",
        "sys:role:info",
        "sys:attachment:page",
        "sys:user:info",
        "sys:attachment:save",
        "sys:role:delete",
        "schedule:save",
        "sys:dict:update",
        "sms:log",
        "sys:dict:save"
    ]
    return success("ok", ret)


@router.get("/dict/type/all")
async def types():
    ret =   [
        {
            "dictType": "post_status",
            "dataList": [
                {
                    "dictLabel": "正常",
                    "dictValue": "1",
                    "labelClass": "primary"
                },
                {
                    "dictLabel": "停用",
                    "dictValue": "0",
                    "labelClass": "danger"
                }
            ]
        },
        {
            "dictType": "user_gender",
            "dataList": [
                {
                    "dictLabel": "男",
                    "dictValue": "0",
                    "labelClass": "primary"
                },
                {
                    "dictLabel": "女",
                    "dictValue": "1",
                    "labelClass": "success"
                },
                {
                    "dictLabel": "未知",
                    "dictValue": "2",
                    "labelClass": "warning"
                }
            ]
        },
        {
            "dictType": "user_status",
            "dataList": [
                {
                    "dictLabel": "正常",
                    "dictValue": "1",
                    "labelClass": "primary"
                },
                {
                    "dictLabel": "停用",
                    "dictValue": "0",
                    "labelClass": "danger"
                }
            ]
        },
        {
            "dictType": "role_data_scope",
            "dataList": [
                {
                    "dictLabel": "自定义数据",
                    "dictValue": "4",
                    "labelClass": ""
                },
                {
                    "dictLabel": "本人数据",
                    "dictValue": "3",
                    "labelClass": ""
                },
                {
                    "dictLabel": "本机构数据",
                    "dictValue": "2",
                    "labelClass": ""
                },
                {
                    "dictLabel": "本机构及子机构数据",
                    "dictValue": "1",
                    "labelClass": ""
                },
                {
                    "dictLabel": "全部数据",
                    "dictValue": "0",
                    "labelClass": ""
                }
            ]
        },
        {
            "dictType": "enable_disable",
            "dataList": [
                {
                    "dictLabel": "启用",
                    "dictValue": "1",
                    "labelClass": "primary"
                },
                {
                    "dictLabel": "禁用",
                    "dictValue": "0",
                    "labelClass": "danger"
                }
            ]
        },
        {
            "dictType": "success_fail",
            "dataList": [
                {
                    "dictLabel": "成功",
                    "dictValue": "1",
                    "labelClass": "primary"
                },
                {
                    "dictLabel": "失败",
                    "dictValue": "0",
                    "labelClass": "danger"
                }
            ]
        },
        {
            "dictType": "login_operation",
            "dataList": [
                {
                    "dictLabel": "登录成功",
                    "dictValue": "0",
                    "labelClass": "primary"
                },
                {
                    "dictLabel": "退出成功",
                    "dictValue": "1",
                    "labelClass": "warning"
                },
                {
                    "dictLabel": "验证码错误",
                    "dictValue": "2",
                    "labelClass": "danger"
                },
                {
                    "dictLabel": "账号密码错误",
                    "dictValue": "3",
                    "labelClass": "danger"
                }
            ]
        },
        {
            "dictType": "params_type",
            "dataList": [
                {
                    "dictLabel": "是",
                    "dictValue": "1",
                    "labelClass": "danger"
                },
                {
                    "dictLabel": "否",
                    "dictValue": "0",
                    "labelClass": "primary"
                }
            ]
        },
        {
            "dictType": "user_super_admin",
            "dataList": [
                {
                    "dictLabel": "否",
                    "dictValue": "0",
                    "labelClass": "primary"
                },
                {
                    "dictLabel": "是",
                    "dictValue": "1",
                    "labelClass": "danger"
                }
            ]
        },
        {
            "dictType": "log_operate_type",
            "dataList": [
                {
                    "dictLabel": "查询",
                    "dictValue": "1",
                    "labelClass": "primary"
                },
                {
                    "dictLabel": "新增",
                    "dictValue": "2",
                    "labelClass": "success"
                },
                {
                    "dictLabel": "修改",
                    "dictValue": "3",
                    "labelClass": "warning"
                },
                {
                    "dictLabel": "删除",
                    "dictValue": "4",
                    "labelClass": "danger"
                },
                {
                    "dictLabel": "导出",
                    "dictValue": "5",
                    "labelClass": "info"
                },
                {
                    "dictLabel": "导入",
                    "dictValue": "6",
                    "labelClass": "info"
                },
                {
                    "dictLabel": "其它",
                    "dictValue": "0",
                    "labelClass": "info"
                }
            ]
        },
        {
            "dictType": "sms_platform",
            "dataList": [
                {
                    "dictLabel": "阿里云",
                    "dictValue": "0",
                    "labelClass": ""
                },
                {
                    "dictLabel": "腾讯云",
                    "dictValue": "1",
                    "labelClass": ""
                },
                {
                    "dictLabel": "七牛云",
                    "dictValue": "2",
                    "labelClass": ""
                },
                {
                    "dictLabel": "华为云",
                    "dictValue": "3",
                    "labelClass": ""
                }
            ]
        },
        {
            "dictType": "schedule_group",
            "dataList": [
                {
                    "dictLabel": "默认",
                    "dictValue": "default",
                    "labelClass": ""
                },
                {
                    "dictLabel": "系统",
                    "dictValue": "system",
                    "labelClass": ""
                }
            ]
        },
        {
            "dictType": "schedule_status",
            "dataList": [
                {
                    "dictLabel": "暂停",
                    "dictValue": "0",
                    "labelClass": "danger"
                },
                {
                    "dictLabel": "正常",
                    "dictValue": "1",
                    "labelClass": "primary"
                }
            ]
        }
    ]
    return success("ok", ret)


@router.get("/menu/nav")
async def nav():
    ret = [
        {
            "id": 22,
            "pid": 0,
            "name": "培养方案",
            "children": [
                {
                    "id": 28,
                    "pid": 12,
                    "children": [],
                    "name": "基础数据管理",
                    "url": "sys/test/index1",
                    "type": 0,
                    "openStyle": 0,
                    "icon": "icon-user",
                    "authority": "",
                    "sort": 0,
                    "createTime": "2023-08-10 00:02:04"
                },
                {
                    "id": 28,
                    "pid": 12,
                    "children": [],
                    "name": "课程管理",
                    "url": "sys/test/index2",
                    "type": 0,
                    "openStyle": 0,
                    "icon": "icon-user",
                    "authority": "",
                    "sort": 0,
                    "createTime": "2023-08-10 00:02:04"
                }
            ],
            "url": "",
            "type": 0,
            "openStyle": 0,
            "icon": "icon-safetycertificate",
            "authority": "",
            "sort": 0,
            "createTime": "2023-08-10 00:02:03"
        },
        {
            "id": 12,
            "pid": 0,
            "children": [
                {
                    "id": 28,
                    "pid": 12,
                    "children": [],
                    "name": "用户管理",
                    "url": "sys/user/index",
                    "type": 0,
                    "openStyle": 0,
                    "icon": "icon-user",
                    "authority": "",
                    "sort": 0,
                    "createTime": "2023-08-10 00:02:04"
                },
                {
                    "id": 18,
                    "pid": 12,
                    "children": [],
                    "name": "机构管理",
                    "url": "sys/org/index",
                    "type": 0,
                    "openStyle": 0,
                    "icon": "icon-cluster",
                    "authority": "",
                    "sort": 1,
                    "createTime": "2023-08-10 00:02:03"
                },
                {
                    "id": 13,
                    "pid": 12,
                    "children": [],
                    "name": "岗位管理",
                    "url": "sys/post/index",
                    "type": 0,
                    "openStyle": 0,
                    "icon": "icon-solution",
                    "authority": "",
                    "sort": 2,
                    "createTime": "2023-08-10 00:02:03"
                },
                {
                    "id": 23,
                    "pid": 12,
                    "children": [],
                    "name": "角色管理",
                    "url": "sys/role/index",
                    "type": 0,
                    "openStyle": 0,
                    "icon": "icon-team",
                    "authority": "",
                    "sort": 3,
                    "createTime": "2023-08-10 00:02:03"
                }
            ],
            "name": "权限管理",
            "url": "",
            "type": 0,
            "openStyle": 0,
            "icon": "icon-safetycertificate",
            "authority": "",
            "sort": 0,
            "createTime": "2023-08-10 00:02:03"
        },
        {
            "id": 1,
            "pid": 0,
            "children": [
                {
                    "id": 2,
                    "pid": 1,
                    "children": [],
                    "name": "菜单管理",
                    "url": "sys/menu/index",
                    "type": 0,
                    "openStyle": 0,
                    "icon": "icon-menu",
                    "sort": 0,
                    "createTime": "2023-08-10 00:02:03"
                },
                {
                    "id": 59,
                    "pid": 1,
                    "children": [],
                    "name": "定时任务",
                    "url": "quartz/schedule/index",
                    "type": 0,
                    "openStyle": 0,
                    "icon": "icon-reloadtime",
                    "sort": 0,
                    "createTime": "2023-08-10 00:02:40"
                },
                {
                    "id": 7,
                    "pid": 1,
                    "children": [],
                    "name": "数据字典",
                    "url": "sys/dict/type",
                    "type": 0,
                    "openStyle": 0,
                    "icon": "icon-insertrowabove",
                    "authority": "",
                    "sort": 1,
                    "createTime": "2023-08-10 00:02:03"
                },
                {
                    "id": 42,
                    "pid": 1,
                    "children": [],
                    "name": "参数管理",
                    "url": "sys/params/index",
                    "type": 0,
                    "openStyle": 0,
                    "icon": "icon-filedone",
                    "authority": "sys:params:all",
                    "sort": 2,
                    "createTime": "2023-08-10 00:02:04"
                },
                {
                    "id": 34,
                    "pid": 1,
                    "children": [],
                    "name": "附件管理",
                    "url": "sys/attachment/index",
                    "type": 0,
                    "openStyle": 0,
                    "icon": "icon-folder-fill",
                    "sort": 3,
                    "createTime": "2023-08-10 00:02:04"
                },
                {
                    "id": 43,
                    "pid": 1,
                    "children": [],
                    "name": "接口文档",
                    "url": "http://127.0.0.1:10901/docs",
                    "type": 0,
                    "openStyle": 1,
                    "icon": "icon-file-text-fill",
                    "sort": 10,
                    "createTime": "2023-08-10 00:02:04"
                }
            ],
            "name": "系统设置",
            "type": 0,
            "openStyle": 0,
            "icon": "icon-setting",
            "sort": 1,
            "createTime": "2023-08-10 00:02:03"
        },
        {
            "id": 33,
            "pid": 0,
            "children": [
                {
                    "id": 47,
                    "pid": 33,
                    "children": [],
                    "name": "代码生成器",
                    "url": "/maku-generator/index.html",
                    "type": 0,
                    "openStyle": 0,
                    "icon": "icon-rocket",
                    "authority": "",
                    "sort": 2,
                    "createTime": "2023-08-10 00:02:17"
                },
                {
                    "id": 48,
                    "pid": 33,
                    "children": [
                        {
                            "id": 50,
                            "pid": 48,
                            "children": [],
                            "name": "短信平台",
                            "url": "message/sms/platform/index",
                            "type": 0,
                            "openStyle": 0,
                            "icon": "icon-whatsapp",
                            "sort": 0,
                            "createTime": "2023-08-10 00:02:26"
                        },
                        {
                            "id": 49,
                            "pid": 48,
                            "children": [],
                            "name": "短信日志",
                            "url": "message/sms/log/index",
                            "type": 0,
                            "openStyle": 0,
                            "icon": "icon-detail",
                            "authority": "sms:log",
                            "sort": 1,
                            "createTime": "2023-08-10 00:02:26"
                        }
                    ],
                    "name": "消息管理",
                    "url": "",
                    "type": 0,
                    "openStyle": 0,
                    "icon": "icon-message",
                    "authority": "",
                    "sort": 2,
                    "createTime": "2023-08-10 00:02:25"
                },
                {
                    "id": 55,
                    "pid": 33,
                    "children": [
                        {
                            "id": 56,
                            "pid": 55,
                            "children": [],
                            "name": "服务监控",
                            "url": "monitor/server/index",
                            "type": 0,
                            "openStyle": 0,
                            "icon": "icon-sever",
                            "authority": "monitor:server:all",
                            "sort": 0,
                            "createTime": "2023-08-10 00:02:33"
                        },
                        {
                            "id": 57,
                            "pid": 55,
                            "children": [],
                            "name": "缓存监控",
                            "url": "monitor/cache/index",
                            "type": 0,
                            "openStyle": 0,
                            "icon": "icon-fund-fill",
                            "authority": "monitor:cache:all",
                            "sort": 2,
                            "createTime": "2023-08-10 00:02:33"
                        },
                        {
                            "id": 58,
                            "pid": 55,
                            "children": [],
                            "name": "在线用户",
                            "url": "monitor/user/index",
                            "type": 0,
                            "openStyle": 0,
                            "icon": "icon-user",
                            "authority": "monitor:user:all",
                            "sort": 3,
                            "createTime": "2023-08-10 00:02:33"
                        }
                    ],
                    "name": "系统监控",
                    "url": "",
                    "type": 0,
                    "openStyle": 0,
                    "icon": "icon-Report",
                    "authority": "",
                    "sort": 10,
                    "createTime": "2023-08-10 00:02:33"
                }
            ],
            "name": "应用管理",
            "url": "",
            "type": 0,
            "openStyle": 0,
            "icon": "icon-appstore",
            "authority": "",
            "sort": 2,
            "createTime": "2023-08-10 00:02:04"
        },
        {
            "id": 38,
            "pid": 0,
            "children": [
                {
                    "id": 39,
                    "pid": 38,
                    "children": [],
                    "name": "登录日志",
                    "url": "sys/log/login",
                    "type": 0,
                    "openStyle": 0,
                    "icon": "icon-solution",
                    "authority": "sys:log:login",
                    "sort": 0,
                    "createTime": "2023-08-10 00:02:04"
                },
                {
                    "id": 46,
                    "pid": 38,
                    "children": [],
                    "name": "操作日志",
                    "url": "sys/log/operate",
                    "type": 0,
                    "openStyle": 0,
                    "icon": "icon-file-text",
                    "authority": "sys:operate:all",
                    "sort": 1,
                    "createTime": "2023-08-10 00:02:04"
                }
            ],
            "name": "日志管理",
            "url": "",
            "type": 0,
            "openStyle": 0,
            "icon": "icon-filedone",
            "authority": "",
            "sort": 3,
            "createTime": "2023-08-10 00:02:04"
        }
    ]
    return success("OK", ret)
